package io.xxx.xbutler.domain.task;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.EnumTypeHandler;

import java.time.LocalDateTime;

@Data
@Accessors(chain = true)
public class PushRecordItem {

    @TableId
    private Long id;

    private Long recordId;

    private Long taskId;

    private Long taskItemId;

    private Integer sn;

    private Long storeId;

    private String storeCode;

    private String storeName;

    private String receiverType;

    private String receiverId;

    private String receiverSerialNo;

    private String receiverName;

    private String robotId;

    private String robotSerialNo;

    private String robotName;

    @TableField(typeHandler = EnumTypeHandler.class)
    private MessageType messageType;

    @TableField(typeHandler = EnumTypeHandler.class)
    private ContentType contentType;

    /**
     * 这里的content是进行替换之后的
     */
    @TableField(typeHandler = Fastjson2TypeHandler.class)
    private JSONObject content;

    /**
     * 检查耗时
     */
    private Long checkElapsedTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime pushStartTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime pushEndTime;

    /**
     * 推送耗时
     */
    private Long pushElapsedTime;

    /**
     * UNKNOWN - 已经推送到探鲸，等到结果回调（待上报）
     * SUCCESS - 收到成功的回调结果（成功）
     * FAIL - 收到失败的回调结果（失败）
     */
    private SendStatus status;

    /**
     * 错误来源
     */
    @TableField(typeHandler = EnumTypeHandler.class)
    private ErrorSource errorSource;

    private Integer errorCode;

    private String errorMessage;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedTime;
}
